﻿using MyFramework.MVCLibrary.View;
using UnityEngine;
using UnityEngine.UI;

public class MainView : BaseView
{
    private Button[] _buttons;

    public MainView(string resourceName, ViewType viewType, ScenesType scenesType) :
        base(resourceName, viewType, scenesType)
    {
    }

    protected override void ViewInit()
    {
        //隐藏的也会查找
        _buttons = ViewTransform.GetComponentsInChildren<Button>(true);
    }

    protected override void RegisterUIEvent()
    {
        foreach (var button in _buttons)
        {
            switch (button.name)
            {
                case "Enter Button":
                    button.onClick.AddListener(() =>
                    {
                        // ShowInfoView showInfoView = (ShowInfoView)ViewManager.GetInstance().OpenView(ViewType.ShowInfoView);
                        //ShowInfoModel info = new ShowInfoModel(1001, "A", "友人A", null);
                        //ShowInfoController.GetInstance().RefreshShowInfo(showInfoView, info);
                        Debug.Log("Enter Button");
                    });
                    break;
                case "Button":
                    button.onClick.AddListener(() => { Debug.Log("Button"); });
                    break;
                case "Exit Button":
                    button.onClick.AddListener(Close);
                    break;
            }
        }
    }
}